
<!DOCTYPE html>

<html>
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>pymatgen.apps.borg.hive &#8212; pymatgen 2020.7.3 documentation</title>
    <link rel="stylesheet" href="../../../../_static/basic.css" type="text/css" />
    <link rel="stylesheet" href="../../../../_static/pygments.css" type="text/css" />
    <script id="documentation_options" data-url_root="../../../../" src="../../../../_static/documentation_options.js"></script>
    <script src="../../../../_static/jquery.js"></script>
    <script src="../../../../_static/underscore.js"></script>
    <script src="../../../../_static/doctools.js"></script>
    <script src="../../../../_static/language_data.js"></script>
    <script async="async" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.7/latest.js?config=TeX-AMS-MML_HTMLorMML"></script>
    <link rel="index" title="Index" href="../../../../genindex.html" />
    <link rel="search" title="Search" href="../../../../search.html" />
 
<script type="text/javascript">
  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-33990148-1']);
  _gaq.push(['_trackPageview']);
</script>

  </head><body>
    <div class="related" role="navigation" aria-label="related navigation">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../../../../genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="../../../../py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="nav-item nav-item-0"><a href="../../../../index.html">pymatgen 2020.7.3 documentation</a> &#187;</li>
          <li class="nav-item nav-item-1"><a href="../../../index.html" >Module code</a> &#187;</li>
          <li class="nav-item nav-item-2"><a href="../../../pymatgen.html" accesskey="U">pymatgen</a> &#187;</li>
        <li class="nav-item nav-item-this"><a href="">pymatgen.apps.borg.hive</a></li> 
      </ul>
    </div>  

    <div class="document">
      <div class="documentwrapper">
          <div class="body" role="main">
            
  <h1>Source code for pymatgen.apps.borg.hive</h1><div class="highlight"><pre>
<span></span><span class="c1"># coding: utf-8</span>
<span class="c1"># Copyright (c) Pymatgen Development Team.</span>
<span class="c1"># Distributed under the terms of the MIT License.</span>

<span class="sd">&quot;&quot;&quot;</span>
<span class="sd">This module define the various drones used to assimilate data.</span>
<span class="sd">&quot;&quot;&quot;</span>

<span class="kn">import</span> <span class="nn">abc</span>
<span class="kn">import</span> <span class="nn">os</span>
<span class="kn">import</span> <span class="nn">glob</span>
<span class="kn">import</span> <span class="nn">logging</span>
<span class="kn">import</span> <span class="nn">json</span>
<span class="kn">import</span> <span class="nn">warnings</span>

<span class="kn">from</span> <span class="nn">monty.io</span> <span class="kn">import</span> <span class="n">zopen</span>
<span class="kn">from</span> <span class="nn">pymatgen.io.vasp.inputs</span> <span class="kn">import</span> <span class="n">Incar</span><span class="p">,</span> <span class="n">Potcar</span><span class="p">,</span> <span class="n">Poscar</span>
<span class="kn">from</span> <span class="nn">pymatgen.io.vasp.outputs</span> <span class="kn">import</span> <span class="n">Vasprun</span><span class="p">,</span> <span class="n">Oszicar</span><span class="p">,</span> <span class="n">Dynmat</span>
<span class="kn">from</span> <span class="nn">pymatgen.io.gaussian</span> <span class="kn">import</span> <span class="n">GaussianOutput</span>
<span class="kn">from</span> <span class="nn">pymatgen.entries.computed_entries</span> <span class="kn">import</span> <span class="n">ComputedEntry</span><span class="p">,</span> \
    <span class="n">ComputedStructureEntry</span>
<span class="kn">from</span> <span class="nn">monty.json</span> <span class="kn">import</span> <span class="n">MSONable</span>

<span class="n">logger</span> <span class="o">=</span> <span class="n">logging</span><span class="o">.</span><span class="n">getLogger</span><span class="p">(</span><span class="vm">__name__</span><span class="p">)</span>


<div class="viewcode-block" id="AbstractDrone"><a class="viewcode-back" href="../../../../pymatgen.apps.borg.hive.html#pymatgen.apps.borg.hive.AbstractDrone">[docs]</a><span class="k">class</span> <span class="nc">AbstractDrone</span><span class="p">(</span><span class="n">MSONable</span><span class="p">,</span> <span class="n">metaclass</span><span class="o">=</span><span class="n">abc</span><span class="o">.</span><span class="n">ABCMeta</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">    Abstract drone class that defines the various methods that must be</span>
<span class="sd">    implemented by drones. Because of the quirky nature of Python&quot;s</span>
<span class="sd">    multiprocessing, the intermediate data representations has to be in the</span>
<span class="sd">    form of python primitives. So all objects that drones work with must be</span>
<span class="sd">    MSONable. All drones must also implement the standard MSONable as_dict() and</span>
<span class="sd">    from_dict API.</span>
<span class="sd">    &quot;&quot;&quot;</span>

<div class="viewcode-block" id="AbstractDrone.assimilate"><a class="viewcode-back" href="../../../../pymatgen.apps.borg.hive.html#pymatgen.apps.borg.hive.AbstractDrone.assimilate">[docs]</a>    <span class="nd">@abc</span><span class="o">.</span><span class="n">abstractmethod</span>
    <span class="k">def</span> <span class="nf">assimilate</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">path</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Assimilate data in a directory path into a pymatgen object. Because of</span>
<span class="sd">        the quirky nature of Python&quot;s multiprocessing, the object must support</span>
<span class="sd">        pymatgen&#39;s as_dict() for parallel processing.</span>

<span class="sd">        Args:</span>
<span class="sd">            path: directory path</span>

<span class="sd">        Returns:</span>
<span class="sd">            An assimilated object</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">return</span></div>

<div class="viewcode-block" id="AbstractDrone.get_valid_paths"><a class="viewcode-back" href="../../../../pymatgen.apps.borg.hive.html#pymatgen.apps.borg.hive.AbstractDrone.get_valid_paths">[docs]</a>    <span class="nd">@abc</span><span class="o">.</span><span class="n">abstractmethod</span>
    <span class="k">def</span> <span class="nf">get_valid_paths</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">path</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Checks if path contains valid data for assimilation, and then returns</span>
<span class="sd">        the valid paths. The paths returned can be a list of directory or file</span>
<span class="sd">        paths, depending on what kind of data you are assimilating. For</span>
<span class="sd">        example, if you are assimilating VASP runs, you are only interested in</span>
<span class="sd">        directories containing vasprun.xml files. On the other hand, if you are</span>
<span class="sd">        interested converting all POSCARs in a directory tree to cifs for</span>
<span class="sd">        example, you will want the file paths.</span>

<span class="sd">        Args:</span>
<span class="sd">            path: input path as a tuple generated from os.walk, i.e.,</span>
<span class="sd">                (parent, subdirs, files).</span>

<span class="sd">        Returns:</span>
<span class="sd">            List of valid dir/file paths for assimilation</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">return</span></div></div>


<div class="viewcode-block" id="VaspToComputedEntryDrone"><a class="viewcode-back" href="../../../../pymatgen.apps.borg.hive.html#pymatgen.apps.borg.hive.VaspToComputedEntryDrone">[docs]</a><span class="k">class</span> <span class="nc">VaspToComputedEntryDrone</span><span class="p">(</span><span class="n">AbstractDrone</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">    VaspToEntryDrone assimilates directories containing vasp output to</span>
<span class="sd">    ComputedEntry/ComputedStructureEntry objects. There are some restrictions</span>
<span class="sd">    on the valid directory structures:</span>

<span class="sd">    1. There can be only one vasp run in each directory.</span>
<span class="sd">    2. Directories designated &quot;relax1&quot;, &quot;relax2&quot; are considered to be 2 parts</span>
<span class="sd">       of an aflow style run, and only &quot;relax2&quot; is parsed.</span>
<span class="sd">    3. The drone parses only the vasprun.xml file.</span>
<span class="sd">    &quot;&quot;&quot;</span>

    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">inc_structure</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="n">parameters</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">data</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Args:</span>
<span class="sd">            inc_structure (bool): Set to True if you want</span>
<span class="sd">                ComputedStructureEntries to be returned instead of</span>
<span class="sd">                ComputedEntries.</span>
<span class="sd">            parameters (list): Input parameters to include. It has to be one of</span>
<span class="sd">                the properties supported by the Vasprun object. See</span>
<span class="sd">                :class:`pymatgen.io.vasp.Vasprun`. If parameters is None,</span>
<span class="sd">                a default set of parameters that are necessary for typical</span>
<span class="sd">                post-processing will be set.</span>
<span class="sd">            data (list): Output data to include. Has to be one of the properties</span>
<span class="sd">                supported by the Vasprun object.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_inc_structure</span> <span class="o">=</span> <span class="n">inc_structure</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_parameters</span> <span class="o">=</span> <span class="p">{</span><span class="s2">&quot;is_hubbard&quot;</span><span class="p">,</span> <span class="s2">&quot;hubbards&quot;</span><span class="p">,</span> <span class="s2">&quot;potcar_spec&quot;</span><span class="p">,</span>
                            <span class="s2">&quot;potcar_symbols&quot;</span><span class="p">,</span> <span class="s2">&quot;run_type&quot;</span><span class="p">}</span>
        <span class="k">if</span> <span class="n">parameters</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">_parameters</span><span class="o">.</span><span class="n">update</span><span class="p">(</span><span class="n">parameters</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_data</span> <span class="o">=</span> <span class="n">data</span> <span class="k">if</span> <span class="n">data</span> <span class="k">else</span> <span class="p">[]</span>

<div class="viewcode-block" id="VaspToComputedEntryDrone.assimilate"><a class="viewcode-back" href="../../../../pymatgen.apps.borg.hive.html#pymatgen.apps.borg.hive.VaspToComputedEntryDrone.assimilate">[docs]</a>    <span class="k">def</span> <span class="nf">assimilate</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">path</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Assimilate data in a directory path into a ComputedEntry object.</span>

<span class="sd">        Args:</span>
<span class="sd">            path: directory path</span>

<span class="sd">        Returns:</span>
<span class="sd">            ComputedEntry</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="n">files</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">listdir</span><span class="p">(</span><span class="n">path</span><span class="p">)</span>
        <span class="k">if</span> <span class="s2">&quot;relax1&quot;</span> <span class="ow">in</span> <span class="n">files</span> <span class="ow">and</span> <span class="s2">&quot;relax2&quot;</span> <span class="ow">in</span> <span class="n">files</span><span class="p">:</span>
            <span class="n">filepath</span> <span class="o">=</span> <span class="n">glob</span><span class="o">.</span><span class="n">glob</span><span class="p">(</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">path</span><span class="p">,</span> <span class="s2">&quot;relax2&quot;</span><span class="p">,</span>
                                              <span class="s2">&quot;vasprun.xml*&quot;</span><span class="p">))[</span><span class="mi">0</span><span class="p">]</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="n">vasprun_files</span> <span class="o">=</span> <span class="n">glob</span><span class="o">.</span><span class="n">glob</span><span class="p">(</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">path</span><span class="p">,</span> <span class="s2">&quot;vasprun.xml*&quot;</span><span class="p">))</span>
            <span class="n">filepath</span> <span class="o">=</span> <span class="kc">None</span>
            <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">vasprun_files</span><span class="p">)</span> <span class="o">==</span> <span class="mi">1</span><span class="p">:</span>
                <span class="n">filepath</span> <span class="o">=</span> <span class="n">vasprun_files</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>
            <span class="k">elif</span> <span class="nb">len</span><span class="p">(</span><span class="n">vasprun_files</span><span class="p">)</span> <span class="o">&gt;</span> <span class="mi">1</span><span class="p">:</span>
                <span class="c1"># Since multiple files are ambiguous, we will always read</span>
                <span class="c1"># the one that it the last one alphabetically.</span>
                <span class="n">filepath</span> <span class="o">=</span> <span class="nb">sorted</span><span class="p">(</span><span class="n">vasprun_files</span><span class="p">)[</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span>
                <span class="n">warnings</span><span class="o">.</span><span class="n">warn</span><span class="p">(</span><span class="s2">&quot;</span><span class="si">%d</span><span class="s2"> vasprun.xml.* found. </span><span class="si">%s</span><span class="s2"> is being parsed.&quot;</span> <span class="o">%</span>
                              <span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">vasprun_files</span><span class="p">),</span> <span class="n">filepath</span><span class="p">))</span>

        <span class="k">try</span><span class="p">:</span>
            <span class="n">vasprun</span> <span class="o">=</span> <span class="n">Vasprun</span><span class="p">(</span><span class="n">filepath</span><span class="p">)</span>
        <span class="k">except</span> <span class="ne">Exception</span> <span class="k">as</span> <span class="n">ex</span><span class="p">:</span>
            <span class="n">logger</span><span class="o">.</span><span class="n">debug</span><span class="p">(</span><span class="s2">&quot;error in </span><span class="si">{}</span><span class="s2">: </span><span class="si">{}</span><span class="s2">&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">filepath</span><span class="p">,</span> <span class="n">ex</span><span class="p">))</span>
            <span class="k">return</span> <span class="kc">None</span>

        <span class="n">entry</span> <span class="o">=</span> <span class="n">vasprun</span><span class="o">.</span><span class="n">get_computed_entry</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_inc_structure</span><span class="p">,</span>
                                           <span class="n">parameters</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parameters</span><span class="p">,</span>
                                           <span class="n">data</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_data</span><span class="p">)</span>

        <span class="c1"># entry.parameters[&quot;history&quot;] = _get_transformation_history(path)</span>
        <span class="k">return</span> <span class="n">entry</span></div>

<div class="viewcode-block" id="VaspToComputedEntryDrone.get_valid_paths"><a class="viewcode-back" href="../../../../pymatgen.apps.borg.hive.html#pymatgen.apps.borg.hive.VaspToComputedEntryDrone.get_valid_paths">[docs]</a>    <span class="k">def</span> <span class="nf">get_valid_paths</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">path</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Checks if paths contains vasprun.xml or (POSCAR+OSZICAR)</span>

<span class="sd">        Args:</span>
<span class="sd">            path: input path as a tuple generated from os.walk, i.e.,</span>
<span class="sd">                (parent, subdirs, files).</span>

<span class="sd">        Returns:</span>
<span class="sd">            List of valid dir/file paths for assimilation</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="p">(</span><span class="n">parent</span><span class="p">,</span> <span class="n">subdirs</span><span class="p">,</span> <span class="n">files</span><span class="p">)</span> <span class="o">=</span> <span class="n">path</span>
        <span class="k">if</span> <span class="s2">&quot;relax1&quot;</span> <span class="ow">in</span> <span class="n">subdirs</span> <span class="ow">and</span> <span class="s2">&quot;relax2&quot;</span> <span class="ow">in</span> <span class="n">subdirs</span><span class="p">:</span>
            <span class="k">return</span> <span class="p">[</span><span class="n">parent</span><span class="p">]</span>
        <span class="k">if</span> <span class="p">(</span><span class="ow">not</span> <span class="n">parent</span><span class="o">.</span><span class="n">endswith</span><span class="p">(</span><span class="s2">&quot;/relax1&quot;</span><span class="p">))</span> <span class="ow">and</span> \
                <span class="p">(</span><span class="ow">not</span> <span class="n">parent</span><span class="o">.</span><span class="n">endswith</span><span class="p">(</span><span class="s2">&quot;/relax2&quot;</span><span class="p">))</span> <span class="ow">and</span> <span class="p">(</span>
                <span class="nb">len</span><span class="p">(</span><span class="n">glob</span><span class="o">.</span><span class="n">glob</span><span class="p">(</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">parent</span><span class="p">,</span> <span class="s2">&quot;vasprun.xml*&quot;</span><span class="p">)))</span> <span class="o">&gt;</span> <span class="mi">0</span> <span class="ow">or</span> <span class="p">(</span>
                <span class="nb">len</span><span class="p">(</span><span class="n">glob</span><span class="o">.</span><span class="n">glob</span><span class="p">(</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">parent</span><span class="p">,</span> <span class="s2">&quot;POSCAR*&quot;</span><span class="p">)))</span> <span class="o">&gt;</span> <span class="mi">0</span> <span class="ow">and</span>
                <span class="nb">len</span><span class="p">(</span><span class="n">glob</span><span class="o">.</span><span class="n">glob</span><span class="p">(</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">parent</span><span class="p">,</span> <span class="s2">&quot;OSZICAR*&quot;</span><span class="p">)))</span> <span class="o">&gt;</span> <span class="mi">0</span><span class="p">)</span>
        <span class="p">):</span>
            <span class="k">return</span> <span class="p">[</span><span class="n">parent</span><span class="p">]</span>
        <span class="k">return</span> <span class="p">[]</span></div>

    <span class="k">def</span> <span class="fm">__str__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="k">return</span> <span class="s2">&quot; VaspToComputedEntryDrone&quot;</span>

<div class="viewcode-block" id="VaspToComputedEntryDrone.as_dict"><a class="viewcode-back" href="../../../../pymatgen.apps.borg.hive.html#pymatgen.apps.borg.hive.VaspToComputedEntryDrone.as_dict">[docs]</a>    <span class="k">def</span> <span class="nf">as_dict</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Returns: MSONABle dict</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">return</span> <span class="p">{</span><span class="s2">&quot;init_args&quot;</span><span class="p">:</span> <span class="p">{</span><span class="s2">&quot;inc_structure&quot;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_inc_structure</span><span class="p">,</span>
                              <span class="s2">&quot;parameters&quot;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parameters</span><span class="p">,</span>
                              <span class="s2">&quot;data&quot;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_data</span><span class="p">},</span>
                <span class="s2">&quot;@module&quot;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="vm">__class__</span><span class="o">.</span><span class="vm">__module__</span><span class="p">,</span>
                <span class="s2">&quot;@class&quot;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="vm">__class__</span><span class="o">.</span><span class="vm">__name__</span><span class="p">}</span></div>

<div class="viewcode-block" id="VaspToComputedEntryDrone.from_dict"><a class="viewcode-back" href="../../../../pymatgen.apps.borg.hive.html#pymatgen.apps.borg.hive.VaspToComputedEntryDrone.from_dict">[docs]</a>    <span class="nd">@classmethod</span>
    <span class="k">def</span> <span class="nf">from_dict</span><span class="p">(</span><span class="bp">cls</span><span class="p">,</span> <span class="n">d</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Args:</span>
<span class="sd">            d (dict): Dict Representation</span>

<span class="sd">        Returns:</span>
<span class="sd">            VaspToComputedEntryDrone</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">return</span> <span class="bp">cls</span><span class="p">(</span><span class="o">**</span><span class="n">d</span><span class="p">[</span><span class="s2">&quot;init_args&quot;</span><span class="p">])</span></div></div>


<div class="viewcode-block" id="SimpleVaspToComputedEntryDrone"><a class="viewcode-back" href="../../../../pymatgen.apps.borg.hive.html#pymatgen.apps.borg.hive.SimpleVaspToComputedEntryDrone">[docs]</a><span class="k">class</span> <span class="nc">SimpleVaspToComputedEntryDrone</span><span class="p">(</span><span class="n">VaspToComputedEntryDrone</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">    A simpler VaspToComputedEntryDrone. Instead of parsing vasprun.xml, it</span>
<span class="sd">    parses only the INCAR, POTCAR, OSZICAR and KPOINTS files, which are much</span>
<span class="sd">    smaller and faster to parse. However, much fewer properties are available</span>
<span class="sd">    compared to the standard VaspToComputedEntryDrone.</span>
<span class="sd">    &quot;&quot;&quot;</span>

    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">inc_structure</span><span class="o">=</span><span class="kc">False</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Args:</span>
<span class="sd">            inc_structure (bool): Set to True if you want</span>
<span class="sd">                ComputedStructureEntries to be returned instead of</span>
<span class="sd">                ComputedEntries. Structure will be parsed from the CONTCAR.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_inc_structure</span> <span class="o">=</span> <span class="n">inc_structure</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_parameters</span> <span class="o">=</span> <span class="p">{</span><span class="s2">&quot;is_hubbard&quot;</span><span class="p">,</span> <span class="s2">&quot;hubbards&quot;</span><span class="p">,</span> <span class="s2">&quot;potcar_spec&quot;</span><span class="p">,</span>
                            <span class="s2">&quot;run_type&quot;</span><span class="p">}</span>

<div class="viewcode-block" id="SimpleVaspToComputedEntryDrone.assimilate"><a class="viewcode-back" href="../../../../pymatgen.apps.borg.hive.html#pymatgen.apps.borg.hive.SimpleVaspToComputedEntryDrone.assimilate">[docs]</a>    <span class="k">def</span> <span class="nf">assimilate</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">path</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Assimilate data in a directory path into a ComputedEntry object.</span>

<span class="sd">        Args:</span>
<span class="sd">            path: directory path</span>

<span class="sd">        Returns:</span>
<span class="sd">            ComputedEntry</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="n">files</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">listdir</span><span class="p">(</span><span class="n">path</span><span class="p">)</span>
        <span class="k">try</span><span class="p">:</span>
            <span class="n">files_to_parse</span> <span class="o">=</span> <span class="p">{}</span>
            <span class="k">if</span> <span class="s2">&quot;relax1&quot;</span> <span class="ow">in</span> <span class="n">files</span> <span class="ow">and</span> <span class="s2">&quot;relax2&quot;</span> <span class="ow">in</span> <span class="n">files</span><span class="p">:</span>
                <span class="k">for</span> <span class="n">filename</span> <span class="ow">in</span> <span class="p">(</span><span class="s2">&quot;INCAR&quot;</span><span class="p">,</span> <span class="s2">&quot;POTCAR&quot;</span><span class="p">,</span> <span class="s2">&quot;POSCAR&quot;</span><span class="p">):</span>
                    <span class="n">search_str</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">path</span><span class="p">,</span> <span class="s2">&quot;relax1&quot;</span><span class="p">,</span> <span class="n">filename</span> <span class="o">+</span> <span class="s2">&quot;*&quot;</span><span class="p">)</span>
                    <span class="n">files_to_parse</span><span class="p">[</span><span class="n">filename</span><span class="p">]</span> <span class="o">=</span> <span class="n">glob</span><span class="o">.</span><span class="n">glob</span><span class="p">(</span><span class="n">search_str</span><span class="p">)[</span><span class="mi">0</span><span class="p">]</span>
                <span class="k">for</span> <span class="n">filename</span> <span class="ow">in</span> <span class="p">(</span><span class="s2">&quot;CONTCAR&quot;</span><span class="p">,</span> <span class="s2">&quot;OSZICAR&quot;</span><span class="p">):</span>
                    <span class="n">search_str</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">path</span><span class="p">,</span> <span class="s2">&quot;relax2&quot;</span><span class="p">,</span> <span class="n">filename</span> <span class="o">+</span> <span class="s2">&quot;*&quot;</span><span class="p">)</span>
                    <span class="n">files_to_parse</span><span class="p">[</span><span class="n">filename</span><span class="p">]</span> <span class="o">=</span> <span class="n">glob</span><span class="o">.</span><span class="n">glob</span><span class="p">(</span><span class="n">search_str</span><span class="p">)[</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span>
            <span class="k">else</span><span class="p">:</span>
                <span class="k">for</span> <span class="n">filename</span> <span class="ow">in</span> <span class="p">(</span>
                        <span class="s2">&quot;INCAR&quot;</span><span class="p">,</span> <span class="s2">&quot;POTCAR&quot;</span><span class="p">,</span> <span class="s2">&quot;CONTCAR&quot;</span><span class="p">,</span> <span class="s2">&quot;OSZICAR&quot;</span><span class="p">,</span> <span class="s2">&quot;POSCAR&quot;</span><span class="p">,</span> <span class="s2">&quot;DYNMAT&quot;</span>
                <span class="p">):</span>
                    <span class="n">files</span> <span class="o">=</span> <span class="nb">sorted</span><span class="p">(</span><span class="n">glob</span><span class="o">.</span><span class="n">glob</span><span class="p">(</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">path</span><span class="p">,</span> <span class="n">filename</span> <span class="o">+</span> <span class="s2">&quot;*&quot;</span><span class="p">)))</span>
                    <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">files</span><span class="p">)</span> <span class="o">&lt;</span> <span class="mi">1</span><span class="p">:</span>
                        <span class="k">continue</span>
                    <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">files</span><span class="p">)</span> <span class="o">==</span> <span class="mi">1</span> <span class="ow">or</span> <span class="n">filename</span> <span class="o">==</span> <span class="s2">&quot;INCAR&quot;</span> <span class="ow">or</span> \
                            <span class="n">filename</span> <span class="o">==</span> <span class="s2">&quot;POTCAR&quot;</span> <span class="ow">or</span> <span class="n">filename</span> <span class="o">==</span> <span class="s2">&quot;DYNMAT&quot;</span><span class="p">:</span>
                        <span class="n">files_to_parse</span><span class="p">[</span><span class="n">filename</span><span class="p">]</span> <span class="o">=</span> <span class="n">files</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span> \
                            <span class="k">if</span> <span class="n">filename</span> <span class="o">==</span> <span class="s2">&quot;POTCAR&quot;</span> <span class="k">else</span> <span class="n">files</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>
                    <span class="k">elif</span> <span class="nb">len</span><span class="p">(</span><span class="n">files</span><span class="p">)</span> <span class="o">&gt;</span> <span class="mi">1</span><span class="p">:</span>
                        <span class="c1"># Since multiple files are ambiguous, we will always</span>
                        <span class="c1"># use the first one for POSCAR and the last one</span>
                        <span class="c1"># alphabetically for CONTCAR and OSZICAR.</span>

                        <span class="k">if</span> <span class="n">filename</span> <span class="o">==</span> <span class="s2">&quot;POSCAR&quot;</span><span class="p">:</span>
                            <span class="n">files_to_parse</span><span class="p">[</span><span class="n">filename</span><span class="p">]</span> <span class="o">=</span> <span class="n">files</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>
                        <span class="k">else</span><span class="p">:</span>
                            <span class="n">files_to_parse</span><span class="p">[</span><span class="n">filename</span><span class="p">]</span> <span class="o">=</span> <span class="n">files</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span>
                        <span class="n">warnings</span><span class="o">.</span><span class="n">warn</span><span class="p">(</span>
                            <span class="s2">&quot;</span><span class="si">%d</span><span class="s2"> files found. </span><span class="si">%s</span><span class="s2"> is being parsed.&quot;</span> <span class="o">%</span>
                            <span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">files</span><span class="p">),</span> <span class="n">files_to_parse</span><span class="p">[</span><span class="n">filename</span><span class="p">]))</span>

            <span class="n">poscar</span><span class="p">,</span> <span class="n">contcar</span><span class="p">,</span> <span class="n">incar</span><span class="p">,</span> <span class="n">potcar</span><span class="p">,</span> <span class="n">oszicar</span><span class="p">,</span> <span class="n">dynmat</span> <span class="o">=</span> <span class="p">[</span><span class="kc">None</span><span class="p">]</span> <span class="o">*</span> <span class="mi">6</span>
            <span class="k">if</span> <span class="s1">&#39;POSCAR&#39;</span> <span class="ow">in</span> <span class="n">files_to_parse</span><span class="p">:</span>
                <span class="n">poscar</span> <span class="o">=</span> <span class="n">Poscar</span><span class="o">.</span><span class="n">from_file</span><span class="p">(</span><span class="n">files_to_parse</span><span class="p">[</span><span class="s2">&quot;POSCAR&quot;</span><span class="p">])</span>
            <span class="k">if</span> <span class="s1">&#39;CONTCAR&#39;</span> <span class="ow">in</span> <span class="n">files_to_parse</span><span class="p">:</span>
                <span class="n">contcar</span> <span class="o">=</span> <span class="n">Poscar</span><span class="o">.</span><span class="n">from_file</span><span class="p">(</span><span class="n">files_to_parse</span><span class="p">[</span><span class="s2">&quot;CONTCAR&quot;</span><span class="p">])</span>
            <span class="k">if</span> <span class="s1">&#39;INCAR&#39;</span> <span class="ow">in</span> <span class="n">files_to_parse</span><span class="p">:</span>
                <span class="n">incar</span> <span class="o">=</span> <span class="n">Incar</span><span class="o">.</span><span class="n">from_file</span><span class="p">(</span><span class="n">files_to_parse</span><span class="p">[</span><span class="s2">&quot;INCAR&quot;</span><span class="p">])</span>
            <span class="k">if</span> <span class="s1">&#39;POTCAR&#39;</span> <span class="ow">in</span> <span class="n">files_to_parse</span><span class="p">:</span>
                <span class="n">potcar</span> <span class="o">=</span> <span class="n">Potcar</span><span class="o">.</span><span class="n">from_file</span><span class="p">(</span><span class="n">files_to_parse</span><span class="p">[</span><span class="s2">&quot;POTCAR&quot;</span><span class="p">])</span>
            <span class="k">if</span> <span class="s1">&#39;OSZICAR&#39;</span> <span class="ow">in</span> <span class="n">files_to_parse</span><span class="p">:</span>
                <span class="n">oszicar</span> <span class="o">=</span> <span class="n">Oszicar</span><span class="p">(</span><span class="n">files_to_parse</span><span class="p">[</span><span class="s2">&quot;OSZICAR&quot;</span><span class="p">])</span>
            <span class="k">if</span> <span class="s1">&#39;DYNMAT&#39;</span> <span class="ow">in</span> <span class="n">files_to_parse</span><span class="p">:</span>
                <span class="n">dynmat</span> <span class="o">=</span> <span class="n">Dynmat</span><span class="p">(</span><span class="n">files_to_parse</span><span class="p">[</span><span class="s2">&quot;DYNMAT&quot;</span><span class="p">])</span>

            <span class="n">param</span> <span class="o">=</span> <span class="p">{</span><span class="s2">&quot;hubbards&quot;</span><span class="p">:</span> <span class="p">{}}</span>
            <span class="k">if</span> <span class="n">poscar</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span> <span class="ow">and</span> <span class="n">incar</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span> <span class="ow">and</span> <span class="s2">&quot;LDAUU&quot;</span> <span class="ow">in</span> <span class="n">incar</span><span class="p">:</span>
                <span class="n">param</span><span class="p">[</span><span class="s2">&quot;hubbards&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="nb">dict</span><span class="p">(</span><span class="nb">zip</span><span class="p">(</span><span class="n">poscar</span><span class="o">.</span><span class="n">site_symbols</span><span class="p">,</span>
                                             <span class="n">incar</span><span class="p">[</span><span class="s2">&quot;LDAUU&quot;</span><span class="p">]))</span>
            <span class="n">param</span><span class="p">[</span><span class="s2">&quot;is_hubbard&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="p">(</span>
                    <span class="n">incar</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">&quot;LDAU&quot;</span><span class="p">,</span> <span class="kc">True</span><span class="p">)</span> <span class="ow">and</span> <span class="nb">sum</span><span class="p">(</span><span class="n">param</span><span class="p">[</span><span class="s2">&quot;hubbards&quot;</span><span class="p">]</span><span class="o">.</span><span class="n">values</span><span class="p">())</span> <span class="o">&gt;</span> <span class="mi">0</span>
            <span class="p">)</span> <span class="k">if</span> <span class="n">incar</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span> <span class="k">else</span> <span class="kc">False</span>
            <span class="n">param</span><span class="p">[</span><span class="s2">&quot;run_type&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span>
            <span class="n">param</span><span class="p">[</span><span class="s2">&quot;potcar_spec&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="n">potcar</span><span class="o">.</span><span class="n">spec</span> <span class="k">if</span> <span class="n">potcar</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span> <span class="k">else</span> <span class="kc">None</span>
            <span class="n">energy</span> <span class="o">=</span> <span class="n">oszicar</span><span class="o">.</span><span class="n">final_energy</span> <span class="k">if</span> <span class="n">oszicar</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span> <span class="k">else</span> <span class="n">Vasprun</span><span class="o">.</span><span class="n">final_energy</span>
            <span class="n">structure</span> <span class="o">=</span> <span class="n">contcar</span><span class="o">.</span><span class="n">structure</span> <span class="k">if</span> <span class="n">contcar</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span> \
                <span class="k">else</span> <span class="n">poscar</span><span class="o">.</span><span class="n">structure</span>
            <span class="n">initial_vol</span> <span class="o">=</span> <span class="n">poscar</span><span class="o">.</span><span class="n">structure</span><span class="o">.</span><span class="n">volume</span> <span class="k">if</span> <span class="n">poscar</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span> <span class="k">else</span> \
                <span class="kc">None</span>
            <span class="n">final_vol</span> <span class="o">=</span> <span class="n">contcar</span><span class="o">.</span><span class="n">structure</span><span class="o">.</span><span class="n">volume</span> <span class="k">if</span> <span class="n">contcar</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span> <span class="k">else</span> \
                <span class="kc">None</span>
            <span class="n">delta_volume</span> <span class="o">=</span> <span class="kc">None</span>
            <span class="k">if</span> <span class="n">initial_vol</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span> <span class="ow">and</span> <span class="n">final_vol</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
                <span class="n">delta_volume</span> <span class="o">=</span> <span class="p">(</span><span class="n">final_vol</span> <span class="o">/</span> <span class="n">initial_vol</span> <span class="o">-</span> <span class="mi">1</span><span class="p">)</span>
            <span class="n">data</span> <span class="o">=</span> <span class="p">{</span><span class="s2">&quot;filename&quot;</span><span class="p">:</span> <span class="n">path</span><span class="p">,</span> <span class="s2">&quot;delta_volume&quot;</span><span class="p">:</span> <span class="n">delta_volume</span><span class="p">}</span>
            <span class="k">if</span> <span class="n">dynmat</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
                <span class="n">data</span><span class="p">[</span><span class="s1">&#39;phonon_frequencies&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">dynmat</span><span class="o">.</span><span class="n">get_phonon_frequencies</span><span class="p">()</span>
            <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_inc_structure</span><span class="p">:</span>
                <span class="n">entry</span> <span class="o">=</span> <span class="n">ComputedStructureEntry</span><span class="p">(</span>
                    <span class="n">structure</span><span class="p">,</span> <span class="n">energy</span><span class="p">,</span> <span class="n">parameters</span><span class="o">=</span><span class="n">param</span><span class="p">,</span> <span class="n">data</span><span class="o">=</span><span class="n">data</span>
                <span class="p">)</span>
            <span class="k">else</span><span class="p">:</span>
                <span class="n">entry</span> <span class="o">=</span> <span class="n">ComputedEntry</span><span class="p">(</span>
                    <span class="n">structure</span><span class="o">.</span><span class="n">composition</span><span class="p">,</span> <span class="n">energy</span><span class="p">,</span> <span class="n">parameters</span><span class="o">=</span><span class="n">param</span><span class="p">,</span> <span class="n">data</span><span class="o">=</span><span class="n">data</span>
                <span class="p">)</span>
            <span class="k">return</span> <span class="n">entry</span>

        <span class="k">except</span> <span class="ne">Exception</span> <span class="k">as</span> <span class="n">ex</span><span class="p">:</span>
            <span class="n">logger</span><span class="o">.</span><span class="n">debug</span><span class="p">(</span><span class="s2">&quot;error in </span><span class="si">{}</span><span class="s2">: </span><span class="si">{}</span><span class="s2">&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">path</span><span class="p">,</span> <span class="n">ex</span><span class="p">))</span>
            <span class="k">return</span> <span class="kc">None</span></div>

    <span class="k">def</span> <span class="fm">__str__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="k">return</span> <span class="s2">&quot;SimpleVaspToComputedEntryDrone&quot;</span>

<div class="viewcode-block" id="SimpleVaspToComputedEntryDrone.as_dict"><a class="viewcode-back" href="../../../../pymatgen.apps.borg.hive.html#pymatgen.apps.borg.hive.SimpleVaspToComputedEntryDrone.as_dict">[docs]</a>    <span class="k">def</span> <span class="nf">as_dict</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Returns: MSONAble dict</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">return</span> <span class="p">{</span><span class="s2">&quot;init_args&quot;</span><span class="p">:</span> <span class="p">{</span><span class="s2">&quot;inc_structure&quot;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_inc_structure</span><span class="p">},</span>
                <span class="s2">&quot;@module&quot;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="vm">__class__</span><span class="o">.</span><span class="vm">__module__</span><span class="p">,</span>
                <span class="s2">&quot;@class&quot;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="vm">__class__</span><span class="o">.</span><span class="vm">__name__</span><span class="p">}</span></div>

<div class="viewcode-block" id="SimpleVaspToComputedEntryDrone.from_dict"><a class="viewcode-back" href="../../../../pymatgen.apps.borg.hive.html#pymatgen.apps.borg.hive.SimpleVaspToComputedEntryDrone.from_dict">[docs]</a>    <span class="nd">@classmethod</span>
    <span class="k">def</span> <span class="nf">from_dict</span><span class="p">(</span><span class="bp">cls</span><span class="p">,</span> <span class="n">d</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Args:</span>
<span class="sd">            d (dict): Dict Representation</span>

<span class="sd">        Returns:</span>
<span class="sd">            SimpleVaspToComputedEntryDrone</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">return</span> <span class="bp">cls</span><span class="p">(</span><span class="o">**</span><span class="n">d</span><span class="p">[</span><span class="s2">&quot;init_args&quot;</span><span class="p">])</span></div></div>


<div class="viewcode-block" id="GaussianToComputedEntryDrone"><a class="viewcode-back" href="../../../../pymatgen.apps.borg.hive.html#pymatgen.apps.borg.hive.GaussianToComputedEntryDrone">[docs]</a><span class="k">class</span> <span class="nc">GaussianToComputedEntryDrone</span><span class="p">(</span><span class="n">AbstractDrone</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">    GaussianToEntryDrone assimilates directories containing Gaussian output to</span>
<span class="sd">    ComputedEntry/ComputedStructureEntry objects. By default, it is assumed</span>
<span class="sd">    that Gaussian output files have a &quot;.log&quot; extension.</span>

<span class="sd">    .. note::</span>

<span class="sd">        Like the GaussianOutput class, this is still in early beta.</span>
<span class="sd">    &quot;&quot;&quot;</span>

    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">inc_structure</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="n">parameters</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">data</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span>
                 <span class="n">file_extensions</span><span class="o">=</span><span class="p">(</span><span class="s2">&quot;.log&quot;</span><span class="p">,)):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Args:</span>
<span class="sd">            inc_structure (bool): Set to True if you want</span>
<span class="sd">                ComputedStructureEntries to be returned instead of</span>
<span class="sd">                ComputedEntries.</span>
<span class="sd">            parameters (list): Input parameters to include. It has to be one of</span>
<span class="sd">                the properties supported by the GaussianOutput object. See</span>
<span class="sd">                :class:`pymatgen.io.gaussianio GaussianOutput`. The parameters</span>
<span class="sd">                have to be one of python&quot;s primitive types, i.e., list, dict of</span>
<span class="sd">                strings and integers. If parameters is None, a default set of</span>
<span class="sd">                parameters will be set.</span>
<span class="sd">            data (list): Output data to include. Has to be one of the properties</span>
<span class="sd">                supported by the GaussianOutput object. The parameters have to</span>
<span class="sd">                be one of python&quot;s primitive types, i.e. list, dict of strings</span>
<span class="sd">                and integers. If data is None, a default set will be set.</span>
<span class="sd">            file_extensions (list):</span>
<span class="sd">                File extensions to be considered as Gaussian output files.</span>
<span class="sd">                Defaults to just the typical &quot;log&quot; extension.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_inc_structure</span> <span class="o">=</span> <span class="n">inc_structure</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_parameters</span> <span class="o">=</span> <span class="p">{</span><span class="s2">&quot;functional&quot;</span><span class="p">,</span> <span class="s2">&quot;basis_set&quot;</span><span class="p">,</span> <span class="s2">&quot;charge&quot;</span><span class="p">,</span>
                            <span class="s2">&quot;spin_multiplicity&quot;</span><span class="p">,</span> <span class="s2">&quot;route_parameters&quot;</span><span class="p">}</span>

        <span class="k">if</span> <span class="n">parameters</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">_parameters</span><span class="o">.</span><span class="n">update</span><span class="p">(</span><span class="n">parameters</span><span class="p">)</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">_data</span> <span class="o">=</span> <span class="p">{</span><span class="s2">&quot;stationary_type&quot;</span><span class="p">,</span> <span class="s2">&quot;properly_terminated&quot;</span><span class="p">}</span>
        <span class="k">if</span> <span class="n">data</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">_data</span><span class="o">.</span><span class="n">update</span><span class="p">(</span><span class="n">data</span><span class="p">)</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">_file_extensions</span> <span class="o">=</span> <span class="n">file_extensions</span>

<div class="viewcode-block" id="GaussianToComputedEntryDrone.assimilate"><a class="viewcode-back" href="../../../../pymatgen.apps.borg.hive.html#pymatgen.apps.borg.hive.GaussianToComputedEntryDrone.assimilate">[docs]</a>    <span class="k">def</span> <span class="nf">assimilate</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">path</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Assimilate data in a directory path into a ComputedEntry object.</span>

<span class="sd">        Args:</span>
<span class="sd">            path: directory path</span>

<span class="sd">        Returns:</span>
<span class="sd">            ComputedEntry</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">try</span><span class="p">:</span>
            <span class="n">gaurun</span> <span class="o">=</span> <span class="n">GaussianOutput</span><span class="p">(</span><span class="n">path</span><span class="p">)</span>
        <span class="k">except</span> <span class="ne">Exception</span> <span class="k">as</span> <span class="n">ex</span><span class="p">:</span>
            <span class="n">logger</span><span class="o">.</span><span class="n">debug</span><span class="p">(</span><span class="s2">&quot;error in </span><span class="si">{}</span><span class="s2">: </span><span class="si">{}</span><span class="s2">&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">path</span><span class="p">,</span> <span class="n">ex</span><span class="p">))</span>
            <span class="k">return</span> <span class="kc">None</span>
        <span class="n">param</span> <span class="o">=</span> <span class="p">{}</span>
        <span class="k">for</span> <span class="n">p</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parameters</span><span class="p">:</span>
            <span class="n">param</span><span class="p">[</span><span class="n">p</span><span class="p">]</span> <span class="o">=</span> <span class="nb">getattr</span><span class="p">(</span><span class="n">gaurun</span><span class="p">,</span> <span class="n">p</span><span class="p">)</span>
        <span class="n">data</span> <span class="o">=</span> <span class="p">{}</span>
        <span class="k">for</span> <span class="n">d</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">_data</span><span class="p">:</span>
            <span class="n">data</span><span class="p">[</span><span class="n">d</span><span class="p">]</span> <span class="o">=</span> <span class="nb">getattr</span><span class="p">(</span><span class="n">gaurun</span><span class="p">,</span> <span class="n">d</span><span class="p">)</span>
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_inc_structure</span><span class="p">:</span>
            <span class="n">entry</span> <span class="o">=</span> <span class="n">ComputedStructureEntry</span><span class="p">(</span><span class="n">gaurun</span><span class="o">.</span><span class="n">final_structure</span><span class="p">,</span>
                                           <span class="n">gaurun</span><span class="o">.</span><span class="n">final_energy</span><span class="p">,</span>
                                           <span class="n">parameters</span><span class="o">=</span><span class="n">param</span><span class="p">,</span>
                                           <span class="n">data</span><span class="o">=</span><span class="n">data</span><span class="p">)</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="n">entry</span> <span class="o">=</span> <span class="n">ComputedEntry</span><span class="p">(</span><span class="n">gaurun</span><span class="o">.</span><span class="n">final_structure</span><span class="o">.</span><span class="n">composition</span><span class="p">,</span>
                                  <span class="n">gaurun</span><span class="o">.</span><span class="n">final_energy</span><span class="p">,</span> <span class="n">parameters</span><span class="o">=</span><span class="n">param</span><span class="p">,</span>
                                  <span class="n">data</span><span class="o">=</span><span class="n">data</span><span class="p">)</span>
        <span class="k">return</span> <span class="n">entry</span></div>

<div class="viewcode-block" id="GaussianToComputedEntryDrone.get_valid_paths"><a class="viewcode-back" href="../../../../pymatgen.apps.borg.hive.html#pymatgen.apps.borg.hive.GaussianToComputedEntryDrone.get_valid_paths">[docs]</a>    <span class="k">def</span> <span class="nf">get_valid_paths</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">path</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Checks if path contains files with define extensions.</span>

<span class="sd">        Args:</span>
<span class="sd">            path: input path as a tuple generated from os.walk, i.e.,</span>
<span class="sd">                (parent, subdirs, files).</span>

<span class="sd">        Returns:</span>
<span class="sd">            List of valid dir/file paths for assimilation</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="n">parent</span><span class="p">,</span> <span class="n">subdirs</span><span class="p">,</span> <span class="n">files</span> <span class="o">=</span> <span class="n">path</span>
        <span class="k">return</span> <span class="p">[</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">parent</span><span class="p">,</span> <span class="n">f</span><span class="p">)</span> <span class="k">for</span> <span class="n">f</span> <span class="ow">in</span> <span class="n">files</span>
                <span class="k">if</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">splitext</span><span class="p">(</span><span class="n">f</span><span class="p">)[</span><span class="mi">1</span><span class="p">]</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">_file_extensions</span><span class="p">]</span></div>

    <span class="k">def</span> <span class="fm">__str__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="k">return</span> <span class="s2">&quot; GaussianToComputedEntryDrone&quot;</span>

<div class="viewcode-block" id="GaussianToComputedEntryDrone.as_dict"><a class="viewcode-back" href="../../../../pymatgen.apps.borg.hive.html#pymatgen.apps.borg.hive.GaussianToComputedEntryDrone.as_dict">[docs]</a>    <span class="k">def</span> <span class="nf">as_dict</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Returns: MSONable dict</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">return</span> <span class="p">{</span><span class="s2">&quot;init_args&quot;</span><span class="p">:</span> <span class="p">{</span><span class="s2">&quot;inc_structure&quot;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_inc_structure</span><span class="p">,</span>
                              <span class="s2">&quot;parameters&quot;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parameters</span><span class="p">,</span>
                              <span class="s2">&quot;data&quot;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_data</span><span class="p">,</span>
                              <span class="s2">&quot;file_extensions&quot;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_file_extensions</span><span class="p">},</span>
                <span class="s2">&quot;@module&quot;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="vm">__class__</span><span class="o">.</span><span class="vm">__module__</span><span class="p">,</span>
                <span class="s2">&quot;@class&quot;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="vm">__class__</span><span class="o">.</span><span class="vm">__name__</span><span class="p">}</span></div>

<div class="viewcode-block" id="GaussianToComputedEntryDrone.from_dict"><a class="viewcode-back" href="../../../../pymatgen.apps.borg.hive.html#pymatgen.apps.borg.hive.GaussianToComputedEntryDrone.from_dict">[docs]</a>    <span class="nd">@classmethod</span>
    <span class="k">def</span> <span class="nf">from_dict</span><span class="p">(</span><span class="bp">cls</span><span class="p">,</span> <span class="n">d</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Args:</span>
<span class="sd">            d (dict): Dict Representation</span>

<span class="sd">        Returns:</span>
<span class="sd">            GaussianToComputedEntryDrone</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">return</span> <span class="bp">cls</span><span class="p">(</span><span class="o">**</span><span class="n">d</span><span class="p">[</span><span class="s2">&quot;init_args&quot;</span><span class="p">])</span></div></div>


<span class="k">def</span> <span class="nf">_get_transformation_history</span><span class="p">(</span><span class="n">path</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">    Checks for a transformations.json* file and returns the history.</span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="n">trans_json</span> <span class="o">=</span> <span class="n">glob</span><span class="o">.</span><span class="n">glob</span><span class="p">(</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">path</span><span class="p">,</span> <span class="s2">&quot;transformations.json*&quot;</span><span class="p">))</span>
    <span class="k">if</span> <span class="n">trans_json</span><span class="p">:</span>
        <span class="k">try</span><span class="p">:</span>
            <span class="k">with</span> <span class="n">zopen</span><span class="p">(</span><span class="n">trans_json</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span> <span class="k">as</span> <span class="n">f</span><span class="p">:</span>
                <span class="k">return</span> <span class="n">json</span><span class="o">.</span><span class="n">load</span><span class="p">(</span><span class="n">f</span><span class="p">)[</span><span class="s2">&quot;history&quot;</span><span class="p">]</span>
        <span class="k">except</span> <span class="ne">Exception</span><span class="p">:</span>
            <span class="k">return</span> <span class="kc">None</span>
    <span class="k">return</span> <span class="kc">None</span>
</pre></div>

            <div class="clearer"></div>
          </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="related" role="navigation" aria-label="related navigation">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../../../../genindex.html" title="General Index"
             >index</a></li>
        <li class="right" >
          <a href="../../../../py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="nav-item nav-item-0"><a href="../../../../index.html">pymatgen 2020.7.3 documentation</a> &#187;</li>
          <li class="nav-item nav-item-1"><a href="../../../index.html" >Module code</a> &#187;</li>
          <li class="nav-item nav-item-2"><a href="../../../pymatgen.html" >pymatgen</a> &#187;</li>
        <li class="nav-item nav-item-this"><a href="">pymatgen.apps.borg.hive</a></li> 
      </ul>
    </div>

    <div class="footer" role="contentinfo">
        &#169; Copyright 2011, Pymatgen Development Team.
      Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 3.1.2.
    </div>
<div class="footer">This page uses <a href="http://analytics.google.com/">
Google Analytics</a> to collect statistics. You can disable it by blocking
the JavaScript coming from www.google-analytics.com.
<script type="text/javascript">
  (function() {
    var ga = document.createElement('script');
    ga.src = ('https:' == document.location.protocol ?
              'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    ga.setAttribute('async', 'true');
    document.documentElement.firstChild.appendChild(ga);
  })();
</script>
</div>

  </body>
</html>